package net.web.milkteapos.bean;

import net.web.milkteapos.bean.Product;

public class SalesLineItem {

	private int quantity;
	private Money money;
	private Product product;
	
	
	public SalesLineItem(Product product) {
		super();
		this.product = product;
		this.quantity = 1;
		summary();
	}
	
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}

	public Money getMoney() {
		return money;
	}

	public void setMoney(Money money) {
		this.money = money;
	}
	
	public void addQuantity() {
		this.quantity++;
		summary();
	}
	
	private void summary() {
		if(money == null)
			money = new Money();
		money.setAmount(quantity * product.getMoney().getAmount());
	}
}
